<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
  	<title>餐厅菜肴管理</title>
  	<%@ include file="../include/jsCss.jsp" %> 
  	<script>
  		//全选
	function checkedAll(t) { 
		$("input[name='sellCheckBox']").each(function(i,item){
			 item.checked = t.checked;
		}); 
	} 
  	//审核通过和不通过
	function auditMealMenu(status) {
		var mealMenuIds = ""; 
		$("input[name='sellCheckBox']").each(function(i,item){
			 if (item.checked == true) {
				 mealMenuIds += item.value + ",";
			 }
		});
		 
		if (mealMenuIds == "") {
			alert("请选择要审核的菜肴!");
			return;
		}
		mealMenuIds = mealMenuIds.substring(0, mealMenuIds.length-1);
		var dt = new Date();
		$.ajax( {
			type : "POST",
			url : "dishes!audit.html",
			data : "mealMenuIds="+mealMenuIds+"&status="+status+"&date=" + dt,
			success : function(data) {
				if ($.trim(data) == 0) {
					if (status == 1) { 
						alert('审核通过成功!');
					}
					if (status == 2) {
						alert('审核不通过成功');
					}
					document.location.reload();
				} else {
					alert('操作失败!');
				}
			}
		}); 
	}
	
	 
  	</script>
  </head>
  
  <body>
  	<form action="dishes!dishesList.html" method="post" id="frmDishes">
		餐厅菜肴管理
		<hr />
		<table width="100%">
			<tr>
				<td>菜肴名称</td>
				<td><input type="text" name="menuName"/></td>  
				<td><input type="button" value="搜索" onclick="javascript:btnSelectMenuName();"/></td>
				<td style="text-align: right;">
					<a href="javascript:;" onclick="auditMealMenu(1)">审核通过</a>	|
					<a href="javascript:;" onclick="auditMealMenu(2)">审核不通过</a> 
				</td>
			</tr>
		</table>

		<table width="100%" border="1">
			<tr>
				<td rowspan="1" ><input type="checkbox" name="sellCheckBoxAll" onclick="checkedAll(this)"/></td>
				<td>编号</td>
				<td>菜肴名称</td> 
				<td>菜肴编号</td>
				<td>价格</td>
				<td>口味</td> 
				<td>菜肴类别</td>
				<td>介绍</td>
				<td>状态</td>
			</tr>
			<s:iterator value="mealMenuDtoList" status="status">
				<tr>
					<td>
						<input type="checkbox" name="sellCheckBox" value="${id }"/>
					</td>
					<td>
						<s:property value="#status.index+1"/>
					</td>
					<td>
						${menuName }
					</td> 
					<td>
						${mealMenuId }
					</td>
					<td>
						${price }
					</td>
					<td>
						<s:if test="taste == 0">
							不辣
						</s:if>
						<s:if test="taste == 1">
							香辣
						</s:if>
						<s:if test="taste == 2">
							香辣(可选)
						</s:if>
						<s:if test="taste == 3">
							微辣
						</s:if>
					</td>
					<td>
						<s:if test="taste==1">
							主食
						</s:if>
						<s:elseif test="taste==2">
							饮料
						</s:elseif>
						<s:elseif test="taste==3">
							凉菜
						</s:elseif>
						<s:elseif test="taste==5">
							水果拼盘
						</s:elseif>
					</td>
					<td>
						${introduce }
					</td>
					 <td>
					 	<s:if test="status == 0">
							审核中
						</s:if>
						<s:if test="status == 1">
							审核通过
						</s:if>
						<s:if test="status == 2">
							审核不通过
						</s:if>
						<s:if test="status == 3">
							作废
						</s:if>
					 </td>
				</tr>
			</s:iterator>
		</table>
		<div>
			<jsp:include page="../include/page.jsp"></jsp:include> 
		</div>
	</form>
     
  </body>
</html>
<<script type="text/javascript">
<!--
	function btnSelectMenuName(){
		$("#frmDishes").submit();
	}
//-->
</script>
